user  {{nginx_user}};
worker_processes  {{nginx_worker_processes}};

error_log  {{nginx_error_log}};
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
pid        {{nginx_pid_path}};


events {
    worker_connections  {{worker_connections}};
    use epoll;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    client_max_body_size 1024m;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;
    #gzip 
    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 8k;
    gzip_types  text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;

    output_buffers 1 32k;
    postpone_output 1460;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;
    send_timeout 5m;
    proxy_intercept_errors on;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

##  upstream start
{% for nginx_server in nginx_servers %}
{% if nginx_server.useBackend %}
upstream {{nginx_server.backends_name}} {
{% for backend in nginx_server.backends %}
    server {{backend.ip_address}}:{{ backend.port }} {{backend.parameters}};
{% endfor %}
}
{% endif %}
{% endfor %}
##  upstream end

## server start
{% for nginx_server in nginx_servers %}

## {{nginx_server.backends_name}}
server {
    listen       {{nginx_server.listenPort}};
    server_name  {{nginx_server.name}};
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X_Real_IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://{{nginx_server.backends_name}};
	}
	 error_page   500 502 503 504  /50x.html;
       	 location = /50x.html {
           	 root   html;
       	}   
        	
}

{% endfor %}
## server end
}
